Component({
    data: {
        active: 0,
        list: [
            {icon: 'credit-pay', text: '资产', url: "/pages/asset/asset"},
            {icon: 'scan', text: '扫码', url: "/pages/code/code"},
            {icon: 'records', text: '维护', url: "/pages/repair/repair"},
            {icon: 'manager-o', text: '我的', url: "/pages/me/me"},
        ]
    },

    methods: {
        onChange(event) {
            this.setData({active: event.detail});
            wx.switchTab({
                url: this.data.list[event.detail].url
            });
        },

        init() {
            const page = getCurrentPages().pop();
            console.log("page", page.route)

            this.setData({
                active: this.data.list.findIndex(item => item.url === `/${page.route}`)
            });
        }
    }
});
